from com.SSHConCore import SSHConByPy


class UseCOMMAND(SSHConByPy):
    def __init__(self, hostname, port, name, password):
        # 调用父类的构造器
        super(UseCOMMAND, self).__init__(hostname, port, name, password)

    # 输入一个命令，返回一个列表
    def get_message_line(self, shell_command):
        stdin, stdout, stderr = self.client.exec_command(shell_command)
        # 输出返回信息
        stdout_info_line = stdout.readlines()
        return stdout_info_line

    # 返回字符串
    def get_message(self, shell_command):
        stdin, stdout, stderr = self.client.exec_command(shell_command)
        # 输出返回信息
        stdout_info_str = stdout.read().decode('utf8')
        return stdout_info_str
